#ifndef REVERSE_ORDER_H
#define REVERSE_ORDER_H
int countReverseOrder(int *a, int begin, int end) {
	if (end - begin <= 1)
		return 0;
	/*if (end - begin == 2) {
		if (a[begin] > a[end])
			return 1;
		else
			return 0;
	}*/
	int middle = begin + ((end - begin) >> 1);
	int left = countReverseOrder(a, begin, middle);
	int right = countReverseOrder(a, middle, end);
	int count = 0;
	for (int i = begin; i < middle; i++) {
		for (int j = middle; j < end; j++) {
			if (a[i] > a[j])
				count++;
		}
	}

	return count + left + right;
}
#endif